<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
<div class="page-head">
    <h3><?php echo $this->__('Business Login Download') ?></h3>
</div>
<div class="padder">

<?php 
if(Mage::getSingleton('customer/session')->getCustomerGroupId()=='4'):
$out_html=array();	
$posts = $this->getPosts(); 
$cat_new='';
$title_new='';
?>
<?php foreach ($posts as $post): ?>

<?php foreach($post->getCats() as $title=>$url){ 
	$cat_new=$url;
	$title_new=$title;
 } ?>
<?php 
if(empty($out_html[$title_new])){
	$out_html[$title_new] = '<div class="head-alt2">';
	$out_html[$title_new].= '<h5 class="title">';
	$out_html[$title_new].= $title_new;
	$out_html[$title_new].= '</h5>';
	$out_html[$title_new].= '</div>';
}

$out_html[$title_new].= '<h2><a href="'.Mage::getBaseUrl('media').$post->getBsfile().'" target="_blank">';

$filename=basename($post->getBsfile());
$extend = pathinfo($filename);
$extend = strtolower($extend["extension"]);

if($extend=='jpg' || $extend=='gif' || $extend=='png' || $extend=='bmp'){
	$out_html[$title_new].= '<img src="'.Mage::getBaseUrl('media'). $post->getBsfile().'" border="0" width="100"/>';
}else{
	
	//$extend='doc';
	//if(file_exists($this->getSkinUrl().'images/icon/'.$extend.'.gif')){
		$out_html[$title_new].='<img src="'.$this->getSkinUrl().'images/icon/'.$extend.'.gif"  onerror="javascript:this.src=\''.$this->getSkinUrl().'images/icon/default.icon.gif\'"/>';
	//}
	$out_html[$title_new].= $post->getTitle();
}

$out_html[$title_new].= '</a></h2>';
?>
<?php endforeach; ?>
<?php 
foreach ($out_html as $sub_html){
	echo $sub_html;
}
?>
<?php else:?>
<h2>You don't have the priority to view this page.</h2>
<?php endif;?>
</div>